<%@ page language="java" pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title><bean:message bundle="UsuarioResources" key="jsp.title.cadastrar"/></title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="">
	<meta http-equiv="description" content="">
	<script src="../js/masks.js" type="text/javascript" language="JavaScript"></script>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>

  <body>

  <logic:present name="usuarioDTO">
    <html:form action="/Usuario/EditarUsuario.do" method="POST" focus="apelido">
    <input type="hidden" name="codigo" value="<bean:write name="usuarioDTO" property="codigo"/>"/>
      <table border="0">
      	<logic:present name="apelidoInvalido">
	        <tr>
	          <td colspan="2" style="color: red;" align="center"><bean:message bundle="UsuarioResources" key="jsp.alert.apelidoIndisponivel"/></td>
	        </tr>
        </logic:present>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.apelido"/>:</td>
          <td><html:text name="usuarioDTO" styleId="apelido" property="apelido" size="15" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.nome"/>:</td>
          <td><html:text name="usuarioDTO" property="nome" size="30" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.email"/>:</td>
          <td><html:text name="usuarioDTO" property="email" size="30" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.endereco"/>:</td>
          <td><html:text name="usuarioDTO" property="endereco" size="30" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.cep"/>:</td>
          <td><html:text name="usuarioDTO" styleId="cep" property="cep" size="10" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.telefone"/>:</td>
          <td><html:text name="usuarioDTO" styleId="telefone" property="telefone" size="15" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.senha"/>:</td>
          <td><html:password property="senha" size="10" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.confirmaSenha"/>:</td>
          <td><html:password property="confirmaSenha" size="10" /></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.dataNascimento"/>:</td>
          <td><input type="text" id="dataNascimento" name="dataNascimento" size="10" value="<bean:write name="usuarioDTO" property="dataNascimento" format="dd/MM/yyyy"/>"/></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.status"/>:</td>
          <td>
          	<logic:equal name="usuarioDTO" property="status" value="A">
          		<input type="checkbox" name="status" value="A" checked/>
          	</logic:equal>
          	<logic:equal name="usuarioDTO" property="status" value="I">
          		<input type="checkbox" name="status" value="I"/>
          	</logic:equal>
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td align="center"><br><html:submit value="Salvar"/></td>
        </tr>
      </table>
    </html:form>
</logic:present>

<logic:present name="sucesso">
      <table border="0">
		<tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.apelido"/>:</td>
          <td><bean:write name="usuarioDTO" property="apelido"/></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.nome"/>:</td>
          <td><bean:write name="usuarioDTO" property="nome"/></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.email"/>:</td>
          <td><bean:write name="usuarioDTO" property="email"/></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.endereco"/>:</td>
          <td><bean:write name="usuarioDTO" property="endereco"/></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.cep"/>:</td>
          <td><bean:write name="usuarioDTO" property="cep"/></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.telefone"/>:</td>
          <td><bean:write name="usuarioDTO" property="telefone"/></td>
        </tr>
        <tr>
          <td><bean:message bundle="UsuarioResources" key="jsp.label.dataNascimento"/>:</td>
          <td><bean:write name="usuarioDTO" property="dataNascimento" format="dd/MM/yyyy"/></td>
        </tr>
      </table>
</logic:present>

<br/><br/>
<a href="../Login/Login.do">Voltar</a>

<script language="JavaScript" type="text/javascript">
	var dateMask = new Mask("dd/mm/yyyy", "date");
	dateMask.attach(document.getElementById("dataNascimento"));

	var telMask = new Mask("(##) ####-####");
	telMask.attach(document.getElementById("telefone"));

	var cepMask = new Mask("#####-###");
	cepMask.attach(document.getElementById("cep"));

	document.getElementById("cep").focus();
	document.getElementById("telefone").focus();
	document.getElementById("apelido").focus();
</script>
  </body>
</html:html>
